package com.yn.common.response.zy;


import com.yn.common.constants.Constants;
import com.yn.common.enums.GenderEnum;
import com.yn.common.enums.LivingAbilityEnum;
import com.yn.common.model.zy.SubscribeInfoDO;
import com.yn.common.utils.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="机构床位预约返回对象", description="机构床位预约")
public class InstitutionInfoResponse {

    @ApiModelProperty(value = "预约id")
    private Integer id;

    @ApiModelProperty(value = "关联id")
    private Integer businessId;

    @ApiModelProperty(value = "机构名称 ")
    private String organName;

    @ApiModelProperty(value = "机构类型 ")
    private String organType;

    @ApiModelProperty(value = "机构区域编码")
    private String regionCode;

    @ApiModelProperty(value = "机构区域编码字符串")
    private String regionCodeStr;

    @ApiModelProperty(value = "机构详细地址 ")
    private String regionDetailInfo;

    //业务类型(0:普通预约 1:急诊预约 2:机构预约)
    @ApiModelProperty(value = "业务类型")
    private Integer businessType;


    @ApiModelProperty(value = "患者姓名", required = true, example = "张三")
    private String userOrderName;

    @ApiModelProperty(value = "家属/联系人电话", required = true, example = "13800138000")
    private String userOrderPhone;

    @ApiModelProperty(value = "患者年龄", example = "65")
    private Integer age;

    @ApiModelProperty(value = "性别")
    private Integer gender;

    @ApiModelProperty(value = "性别字符串")
    private String genderStr;

    @ApiModelProperty(value = "医保类型:字典")
    private String medicalInsuranceType;

    @ApiModelProperty(value = "医保类型字符串")
    private String medicalInsuranceTypeStr;

    @ApiModelProperty(value = "生活能力: 0-自理 1-半自理 2-不能自理", example = "0")
    private Integer livingAbility;

    @ApiModelProperty(value = "生活能力字符串")
    private String livingAbilityStr;

    @ApiModelProperty(value = "接送地址", example = "北京市朝阳区XX街道")
    private String transferAddress;

    @ApiModelProperty(value = "与患者关系:字典")
    private String relationType;

    @ApiModelProperty(value = "与患者关系字符串")
    private String relationTypeStr;

    @ApiModelProperty(value = "健康状况简述")
    private String healthStatus;



    @NotNull(message = "预计出院时间不能为空")
    @ApiModelProperty(value = "预计出院日期", required = true, example = "2025-08-15")
    private String estDischargeTime;

    // 备注信息
    @ApiModelProperty(value = "备注信息")
    private String remark;

    @ApiModelProperty(value = "创建人id")
    private Integer appUserId;

    @ApiModelProperty(value = "更新人id")
    private Integer updateUserId;

    @ApiModelProperty(value = "创建时间")
    private String createTime;

    @ApiModelProperty(value = "更新时间")
    private String updateTime;

    public static InstitutionInfoResponse transform(SubscribeInfoDO infoDO) {
        InstitutionInfoResponse response = new InstitutionInfoResponse();

        response.setId(infoDO.getId());
        response.setBusinessId(infoDO.getBusinessId());
        response.setBusinessType(infoDO.getBusinessType());
        response.setUserOrderName(infoDO.getUserOrderName());
        response.setUserOrderPhone(infoDO.getUserOrderPhone());

        if(infoDO.getAge() != null){
            response.setAge(infoDO.getAge());
        }
       if(infoDO.getGender() != null){
            response.setGender(infoDO.getGender());
            response.setGenderStr(GenderEnum.getByCode(infoDO.getGender()).getName());
        }
       if(infoDO.getMedicalInsuranceType() != null){
            response.setMedicalInsuranceType(infoDO.getMedicalInsuranceType());
        }
       if(infoDO.getLivingAbility() != null){
            response.setLivingAbility(infoDO.getLivingAbility());
            response.setLivingAbilityStr(LivingAbilityEnum.getByCode(infoDO.getLivingAbility()).getName());
        }
       if(infoDO.getTransferAddress() != null){
            response.setTransferAddress(infoDO.getTransferAddress());
        }
       if(infoDO.getRelationType() != null){
            response.setRelationType(infoDO.getRelationType());
        }
       if(infoDO.getHealthStatus() != null){
            response.setHealthStatus(infoDO.getHealthStatus());
        }
       if(infoDO.getEstDischargeTime() != null){
            response.setEstDischargeTime(DateUtil.dateToStr(infoDO.getEstDischargeTime(), Constants.DATE_FORMAT));
        }
        if(infoDO.getRemark() != null){
            response.setRemark(infoDO.getRemark());
        }
        response.setCreateTime(DateUtil.dateToStr(infoDO.getCreateTime(), Constants.DATE_FORMAT));
        response.setUpdateTime(DateUtil.dateToStr(infoDO.getUpdateTime(), Constants.DATE_FORMAT));
        response.setAppUserId(infoDO.getAppUserId());
        response.setUpdateUserId(infoDO.getUpdateUserId());

        return response;
    }
}
